#!/bin/bash

TEST_CNF=./test_cnf_2.sh

FAILED=0
SUCCESS=0
ERROR=0
TOTAL=0
THREADS=64

for cnf in *_without_unary.cnf
do

	echo "Testing file: $cnf"
	PREFIX=`echo $cnf | sed s/".cnf"//g`
	$TEST_CNF $PREFIX $THREADS
	RETURN=$?

	if [[ "$RETURN" == "1" ]] || [[ "$RETURN" == "2" ]]
	then
		echo -e '\e[33;1mSomething wrong has happened.\e[m'
		let ERROR++
	fi

	if [[ "$RETURN" == "10" ]]
	then
		echo -e '\e[32;1mSolutions MATCH\e[m'
		let SUCCESS++
	fi

	if [[ "$RETURN" == "20" ]]
        then
                echo -e '\e[31;1mSolutions DO NOT MATCH\e[m'
		let FAILED++
        fi

	let TOTAL++

done

echo
echo "Summary:"

if [[ "$SUCCESS" == "$TOTAL" ]]
then

	echo -e "\e[32;1mAll $TOTAL files matched!\e[m"

else

	echo -e "\e[31;1mThere were $ERROR errors and $FAILED mismatches of $TOTAL\e[m"

fi


